package com.jxmcloud.business.cut.service.impl.database;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.jxmcloud.business.cut.mapper.database.IRewardPoolRecordDBMapper;
import com.jxmcloud.business.cut.model.database.DBRewardPoolRecord;
import com.jxmcloud.business.cut.model.query.RewardPoolRecordQuery;
import com.jxmcloud.business.cut.service.database.IRewardPoolRecordDBService;
import com.jxmcloud.business.cut.vo.RewardPoolRecordPageVo;
import com.jxmcloud.business.cut.vo.RewardPoolRecordVo;
import com.jxmcloud.business.cut.vo.RewardPoolSummary;
import org.springframework.stereotype.Service;

@Service
public class RewardPoolRecordDBServiceImpl extends ServiceImpl<IRewardPoolRecordDBMapper, DBRewardPoolRecord> implements IRewardPoolRecordDBService {

    @Override
    public RewardPoolRecordPageVo getRewardPoolRecordPage(RewardPoolRecordQuery query) {
        RewardPoolRecordPageVo rewardPoolRecordPageVo = new RewardPoolRecordPageVo();
        IPage<RewardPoolRecordVo> page = this.baseMapper.selectRewardPoolRecordPage(query);
        RewardPoolSummary summary = this.baseMapper.selectRewardPoolSum();
        rewardPoolRecordPageVo.setPage(page)
                .setInTotal(summary.getInTotal())
                .setOutTotal(summary.getOutTotal())
                .setCurrentPoolAmount(summary.getCurrentPoolAmount());
        return rewardPoolRecordPageVo;
    }
}
